package cn.doitedu;

import com.clearspring.analytics.stream.cardinality.HyperLogLog;

import java.io.*;

public class HLLAcc {

    private byte[] hllBytes;

    public HLLAcc() throws IOException {

        // 构造一个空的Hll对象
        HyperLogLog hll = new HyperLogLog(14);


        // 然后序列化成字节
        byte[] bytes = hll.getBytes();


        // 赋值给成员变量
        this.hllBytes = bytes;

    }


    public HyperLogLog getHyperLogLog() throws IOException, ClassNotFoundException {


        HyperLogLog logLog = HyperLogLog.Builder.build(this.hllBytes);

        return logLog;

    }


    public void setHyperLogLog(HyperLogLog logLog) throws IOException {

        byte[] bytes = logLog.getBytes();
        this.hllBytes = bytes;

    }


    public byte[] getHllBytes() {
        return hllBytes;
    }



}
